﻿using System;
using System.Reflection;

namespace HiStaff.Domain
{
    public static class GetDomain
    {
        public static object GetObjectByName(string domainName)
        {
            Type objDomain = Assembly.GetExecutingAssembly().GetType("HiStaff.Domain." + domainName, false, true);
            if (objDomain != null && objDomain.BaseType == typeof(Entity))
            {
                // Get the default constructor
                ConstructorInfo ci = objDomain.GetConstructor(System.Type.EmptyTypes);
                return ci.Invoke(null);
            }
            else return null;
        }
    }
}
